package edu.fsu.cs.SHPE;

import java.net.ConnectException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class SponsorActivity extends Activity {
	private static final String TAG = "edu.fsu.cs.SHPE.SponsorActivity";
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.sponsor);
		setTitle("Sponsor Information");
		
		SponsorContainer sponsor = null;
		try {
			sponsor = new SponsorContainer(Conference.insertId(getString(R.string.getSponsor), getIntent().getLongExtra("id", -1)));
		} catch (ConnectException e) {
			Toast.makeText(this, "Unable to Connect to Server", Toast.LENGTH_SHORT).show();
			e.printStackTrace();
		}
		
		if(sponsor == null){
			Log.i(TAG, "Unable to get speaker");
			finish();
		}
		
		Sponsor tmpSponsor = sponsor.get(0);
		
		TextView tmp;
		
		
		if(tmpSponsor.getLogo() != null){
			ImageView image = (ImageView)findViewById(R.id.imgLogo);
			image.setImageDrawable(tmpSponsor.getLogo());
		}
		
		if(tmpSponsor.getName() != null){
			tmp = (TextView)findViewById(R.id.txtName);
			tmp.setText(tmpSponsor.getName());
		}
		
		if(tmpSponsor.getWebsite() != null){
			tmp = (TextView)findViewById(R.id.txtWebsite);
			tmp.setText(tmpSponsor.getWebsite());
		}
		
		
		tmp = (TextView)findViewById(R.id.txtRecruiting);
		if(tmpSponsor.isRecruiting())
			tmp.setText("Currently Recruiting");
		else
			tmp.setText("Currently Not Recruiting");
		
		tmp = (TextView)findViewById(R.id.txtStudents);
		if(tmpSponsor.isAcceptsInternationStudents())
			tmp.setText("Accepting International Students");
		else
			tmp.setText("Not Accepting International Students");
		
	}

}
